import express from "express"

const app = express()

// 指定dist文件夹为静态资源目录
app.use(express.static("dist"))

const template = `
  <html>
    <head>
      <title>React Fiber</title>
      <script src="index.js"></script>
      <link rel='stylesheet' href='index.css' />
    </head>
    <body>
      <div id="root"></div>
      <script src="bundle.js"></script>
    </body>
  </html>
`

app.get("/", (req, res) => {
  res.send(template)
})

app.get("/index.css", (req, res) => {
  setTimeout(()=>{
    res.send(`
    body{
      background-color: yellow
    }
    `)
  }, 5000)
})

app.listen(3002, () => console.log("server is running"))
